 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page session="true" import="servlets.*" %>
<%@ page session="true" import="classes.*" %>
<%@ page session="true" import="beans.*" %>
<%@ page session="true" import="java.sql.ResultSet" %> 
<%  	session = request.getSession(true); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@page import="java.util.List"%><html class="js" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sistema de Noticias</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 

<%@ include file="inc_head.jsp" %>  
<script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({ 
	// General options 
	mode : "textareas", 
	theme : "advanced",
	plugins : "pagebreak,style,layer,advhr,advlink,emotions,contextmenu,paste,visualchars,nonbreaking,xhtmlxtras",

	// Theme options
	theme_advanced_buttons1 : "bold,italic,underline,|,fontselect,fontsizeselect",
	theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,blockquote,|,link,unlink,anchor,|,forecolor,backcolor",
	theme_advanced_buttons3 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom", 
	theme_advanced_resizing : true,

	// Example content CSS (should be your site CSS)
	content_css : "css/example.css",

	// Drop lists for link/image/media/template dialogs
	template_external_list_url : "js/template_list.js",
	external_link_list_url : "js/link_list.js",
	external_image_list_url : "js/image_list.js",
	media_external_list_url : "js/media_list.js",

	// Replace values for the template plugin
	template_replace_values : {
		username : "Some User",
		staffid : "991234"
	}
});
</script>

</head>
<body>  
<div id="page"> 
  <div id="wrapper"> 
    <div id="header"> <a href="?pg=index"><img src="index_arquivos/logo.png" alt="" id="logo"></a> 
           <h2><a href="Home"></a></h2> 
      <div class="slogan" style="color:#ffffff"></div> 
    </div> 
    <div id="left-col"> 
    
   <%@ include file="inc_menutop.jsp" %>   

      
      <!-- /nav -->  
      <div id="content"> 
        <div class="dbx-box" id="block-block"> 
          <div> 
            <% if (request.getParameter("msg_sucesso") != null) { %> 
            <div id="msg_sucesso"><% out.print(request.getParameter("msg_sucesso")); %></div>
            <% } %>
              <% if (request.getParameter("msg_erro") != null) { %> 
            <div id="msg_erro"><% out.print(request.getParameter("msg_erro")); %></div>
            <% } %> 
            
            <h1>Noticias<% 
            				String nome_categoria = (String)session.getValue("nome_categoria");
            				if(nome_categoria != "") {
            					out.print(" - " + nome_categoria);
            				}	
            				
            				%></h1>

  
  
				<%  	List<Noticia> noticias  = (List<Noticia>)session.getValue("noticias"); %> 
				    
				<% for(int i = 0; i < noticias.size(); i++) {
					Noticia noticia = (Noticia)noticias.get(i);  
					String url_imagem = "";
					String url_video = "";
					
					NoticiaDAO noticiaDAO = new NoticiaJDBC();
					List<Imagem> imagens = noticiaDAO.findAllImagens(noticia.getId());
					
					
					if(imagens != null && imagens.size() > 0) {
						for(int j = 0; j < imagens.size(); j++) {
							Imagem imagem = imagens.get(j);
							url_imagem += "<div style=\"float:right;margin-left:4px\" ><img src=\""+imagem.getUrl()+"\" width=\"70px\"></div>";
						}  
					} 		
					 

         		
         	 	%>  
            
                    <ul>
                    
                        <li>   
                        	<% if(url_imagem != ""){ out.print(url_imagem);} %>                   	
                        	 <strong><a href="NoticiasVer?id=<%  out.print(noticia.getId()); %>"><%  out.print(noticia.getTitulo()); %></a></strong>  <img src="css/rating_<% VotoDAO votoDAO = new VotoJDBC(); out.print(Math.round(votoDAO.avg(noticia.getId()))); %>_mini.gif"> 
 							
                         	<% if(noticia.getTags() != "") {
                         	CategoriaDAO categoriaDAO = new CategoriaJDBC();
                         	AutorDAO autorDAO = new AutorJDBC();
                         	TagDAO tagDAO = new TagJDBC();
                         	
                         %>
                         		 	<br />
                         		 	 <i>Categoria:</i> <%  out.print(categoriaDAO.findById(noticia.getId_categoria()).getNome()); %><br />
	                         		 <i>Tags:</i> <%  out.print(tagDAO.findByIdNoticia(noticia.getId())); %>  <br />
	                         		 <i>Autor:</i> <%  out.print(autorDAO.findById(noticia.getId_autor()).getNome()); %> <br />
	                         		 <i>Data: </i>           <%  out.print(noticia.data_ddmmyyyy()); %> 		
                         	<% } %> <br />  
  							<div style="clear:both"></div> 
                        </li>
                   </ul> 
                    
                <%    
				}
				%>   

     
     <br /><br />
     





		</div> 
        </div> 
      </div> 
      <div id="footer">&nbsp;</div> 
    </div> 
    
    
   <%@ include file="inc_menu.jsp" %>  



    <hr class="hidden"> 
  </div> 
</div> 
</body>
</html>
